let print = console.log;
// let [N, M] = readline().split(' ');
/* 

let [N, M] = '4 4'.split(' ');
N = +N;
M = +M;

let X = 0, Y = 1, B = 2, G = 3;

*/



//|||||||||||||2|||||||||||||\\
// let [N, M] = readline().split(' ');
let [N, M] = '50000 50000'.split(' ');
N = +N;
M = +M;

while (M <= Math.pow(2, N) && M > 1 && N > 1) {
  M--;
  N--;
}

if (N >= 2) {
    let maxNum = Math.floor(M/(2 - 1/Math.pow(2, N - 1)));
    print(maxNum);
} else {
    print(M);
}

//||||||||||||||||||3||||||||||||||||\\
// let n = parseInt(readline());
// let arr = readline().split(' ');
let n = parseInt('5');
let arr = '2 7 4 5 9'.split(' ');

/*
let max, maxIndex, players = [0, 0], count = 0;
arr = arr.map(x => +x);

while (arr.length) {
  
  // find
  max = Math.max(...arr);

  // add
  players[count % 2] += max;
  
  // delete
  maxIndex = arr.findIndex(x => x === max);
  arr.splice(maxIndex, 1);

  // next
  count++;
}

print(players[0] - players[1]);
*/

let max, players = [0, 0], count = 0;

arr.sort();

while (arr.length) {
  
  // emmmm
  max = +arr.pop();

  // add
  players[count % 2] += max;

  // next
  count++;
}

print(players[0] - players[1]);
